# cards.py

import random

suits = ['♠', '♥', '♦', '♣']
ranks = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']

class Deck:
    def __init__(self):
        rank_map = {'A':'ace','2':'2','3':'3','4':'4','5':'5','6':'6','7':'7','8':'8','9':'9','10':'10','J':'jack','Q':'queen','K':'king'}
        suit_map = {'♠':'spades','♥':'hearts','♦':'diamonds','♣':'clubs'}
        self.cards = []
        for suit in suits:
            for rank in ranks:
                rank_name = rank_map[rank]
                suit_name = suit_map[suit]
                image_file = f"{rank_name}_of_{suit_name}.png"
                self.cards.append({'rank': rank, 'suit': suit, 'image_file': image_file})
        self.shuffle()

    def shuffle(self):
        random.shuffle(self.cards)

    def deal_card(self):
        if not self.cards:
            return None
        return self.cards.pop()